
//
//  MidView.swift
//  MyWidgetExtension
//
//  Created by netease on 2024/12/26.
//

import SwiftUI

public struct MidView: View {
    
    let userName: String
    let quote: String
    
    public init(userName: String, quote: String) {
        self.userName = userName
        self.quote = quote
    }
    
    
    public var body: some View {
        VStack {
            // 左右两个 View
            HStack {
                Spacer()
                // 左 View
                VStack(alignment: .leading) {
                    Spacer()
                    Text("所有快乐都向你靠拢，所有好运都在路上。")
                        .font(.system(size: 19.0))
                        .fontWeight(.semibold)
                        .minimumScaleFactor(0.5)
                        .foregroundColor(.white)
                    
                    Spacer()
                    
                    Text("加油，\(userName)！😄")
                        .font(.system(size: 16.0))
                        .minimumScaleFactor(0.5)
                        .foregroundColor(.white)
                    Spacer()
                    Text("网络口令：\(quote)！")
                        .font(.system(size: 16.0))
                        .minimumScaleFactor(0.5)
                        .foregroundColor(.white)
                    Spacer()
                }
                
                Spacer()
                
                // 右 View
                VStack {
                    Spacer()
                    Text("06")
                        .font(.system(size: 50.0))
                        .fontWeight(.semibold)
                        .foregroundColor(.white)
                        .padding(EdgeInsets(top: -10.0, leading: 0.0, bottom: -10.0, trailing: 0.0))
                    Text("06月 周一")
                        .lineLimit(1)
                        .minimumScaleFactor(0.5)
                        .font(.system(size: 14.0))
                        .foregroundColor(.white)
                    Spacer()
                    Link(destination: URL(string: "ma172app://radar")!) {
                        Text("去分享")
                            .fixedSize()
                            .font(.system(size: 14.0))
                            .padding(EdgeInsets(top: 5.0, leading: 20.0, bottom: 5.0, trailing: 20.0))
                            .background(Color.white)
                            .foregroundColor(.black)
                            .cornerRadius(12.0)
                    }
                    Spacer()
                }
                Spacer()
            }
            .padding(EdgeInsets(top: 0.0, leading: 10.0, bottom: 0.0, trailing: 10.0))
        }
        .background{
            // 背景图片
            Image("bgImage")
                .resizable()
        }
    }
}

#Preview {
    MidView(userName: "xxx", quote: "xxx")
}
